/////////////////////////////////////////////////////////////
// File Name	:	"Messages.cpp"
//
// Author Name	:	Brandon Layton (BL)
//
// Purpose:		:	Various messages that can be sent
/////////////////////////////////////////////////////////////

#include "Messages.h"
#include "../tools/Util.h"

CCreateBulletMessage::CCreateBulletMessage(CBase * pOwner, int imageID, float damage, bool enemy, vector2D velocity, vector2D position, bool useParticle, string & particleType, float fTravelDistance, bool bCanCollide, bool slow, bool impact, float AOE) : CBaseMessage(MSG_CREATE_BULLET)
{
	m_bEnemy = enemy;
	m_pOwner = pOwner;
	m_pOwner->AddRef();
	m_vVelocity = velocity;
	m_vPosition = position;
	m_fDistance = fTravelDistance;

	m_bUseParticle = useParticle;
	m_szParticleType = particleType;
	m_nImageID = imageID;
	m_fDamage = damage;
	m_bCanCollide = bCanCollide;
	m_bSlow = slow;
	m_bImpact = impact;
	m_fAOE = AOE;
}

CCreateBulletMessage::~CCreateBulletMessage()
{
	m_pOwner->Release();
}


/*CCreateNPCMessage::CCreateNPCMessage(std::string type, vector2D position, float fCurrentHealth, bool bCustomID, unsigned int nID) : CBaseMessage(MSG_CREATE_NPC)
{
	tNPCDef * def = CNPC::GetDefByType(type);
	if(def == NULL)
	{
		COUT("ERROR creating type" << type << " In CCreateNPCMessage");
	}
	else
	{
		if(bCustomID)
			this->nID = nID;
		vPosition = position;
		typeName = def->typeName;
		nNPCType = def->nNPCType;
		bEnemy = def->bEnemy;
		fMaxSpeed = def->fMaxSpeed;
		fMaxHealth = def->fMaxHealth;
		if(fCurrentHealth != -1000.0f)
			fStartDamage = fMaxHealth - fCurrentHealth;
		else
			fStartDamage = 0.0f;
		fDefense = def->fDefense;
		fMinAttackDamage = def->fMinAttackDamage;
		fMaxAttackDamage = def->fMaxAttackDamage;
		fAttackRange = def->fAttackRange;
		bRanged = def->bRanged;
		fSightRange = def->fSightRange;
		fCaptureSpeed = def->fCaptureSpeed;
		fMovementSpeed = def->fMovementSpeed;
		fAreaOfEffectRadius = def->fAreaOfEffectRadius;
		szParticleType = def->szParticleType;
		nBulletImageID = def->nBulletImageID;
		rCollision = def->rCollision;
		fBulletSpeed = def->fBulletSpeed;
		fAttackSpeed = def->fAttackSpeed;
	}
}

CCreateNPCMessage::~CCreateNPCMessage()
{

}*/

CCreateExplosionMessage::CCreateExplosionMessage(float fPosX, float fPosY, float fVelX, float fVelY) : CBaseMessage(MSG_CREATE_EXPLOSION)
{
	m_fPosX = fPosX;
	m_fPosY = fPosY;

	m_fVelX = fVelX;
	m_fVelY = fVelY;
}

CCreateParticleMessage::CCreateParticleMessage(int nImageID, unsigned int uiLayer, float fPosX, float fPosY, float fVelX, float fVelY, float fLife, float fScaleX, float fScaleY, float fRotation, float fGravity, float fGravityDirection) : CBaseMessage(MSG_CREATE_PARTICLE)
{
	m_nImageID = nImageID;
	m_fPosX = fPosX;
	m_fPosY = fPosY;
	m_fTotalLife = fLife;
	m_fScaleX = fScaleX;
	m_fScaleY = fScaleY;
	m_fRotation = fRotation;
	m_fGravity = fGravity;
	m_fGravityDirection = fGravityDirection;
	m_fVelX = fVelX;
	m_fVelY = fVelY;
}


CDestroyObjectMessage::CDestroyObjectMessage(CBase *pObject) : CBaseMessage(MSG_DESTROY_OBJECT)
{
	m_pObject = pObject;
	m_pObject->AddRef();
}

CDestroyObjectMessage::~CDestroyObjectMessage()
{
	m_pObject->Release();
}



CCreateAOEMessage::CCreateAOEMessage(CBase * pOwner, float fLife, float fBulletLife, float fRadius, 
		float fSplashDamageRadius, float fDamagePerBullet, int nBulletImageID, string & szBulletParticleType, string & szSplashParticleType,
		int nIncomingSound, int nImpactSound, bool bIsEnemy, int nMarkerImage, bool bSlow, vector2D position) : CBaseMessage(MSG_CREATE_AOE),
		m_pOwner(pOwner),
		m_fLife(fLife),
m_fBulletLife(fBulletLife),
m_fRadius(fRadius),
m_fSplashDamageRadius(fSplashDamageRadius),
m_fDamagePerBullet(fDamagePerBullet),
m_nBulletImageID(nBulletImageID),
m_szBulletParticleType(szBulletParticleType),
m_szSplashParticleType(szSplashParticleType),
m_nIncomingSound(nIncomingSound),
m_nImpactSound(nImpactSound),
m_bIsEnemy(bIsEnemy),
m_nMarkerImage(nMarkerImage),
m_bSlow(bSlow),
m_vPosition(position)
{

}